package com.shujia.java.day17.demo2;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

/**
* @Description: Demo2
* @Author: �����
* @Date: 2019/8/19 11:08
 *
 *
 * IO��û�йر�֮ǰ ����ɾ��
*/
public class Demo2 {
    public static void main(String[] args) throws Exception{
        File file = new File("test1.txt");
        //�� ռ���ļ�
        FileInputStream fis = new FileInputStream(file);
        //д �����Ҳ����ļ� �ᴴ��һ�����ļ�

        File file1 = new File("test3.txt");
        FileOutputStream fos = new FileOutputStream(file1);
        byte[] bytes = new byte[1024];
        int len;
        //����Ҳ�ǿ�
        while ((len=fis.read(bytes))!=-1){
            //�ļ�����Ϊ��  ˵�����д����Ǹ���
            fos.write(bytes,0,len);
        }

        //���ļ�ռ��֮�� ����ɾ��
        System.out.println(file.delete());
        System.out.println(file1.delete());

        fos.close();
        fis.close();

    }
}
